var express = require('express');
const role_check=require('./role')
var router = express.Router();
const admin={
    "code": 0,
    "message": "admin获取权限成功",
    "data": [
        {
            "name": "订单管理",
            "children": [
                {
                    "name": "订单列表"
                },
                {
                    "name": "生产管理",
                    "children": [
                        {
                            "name": "生产列表"
                        },
                        {
                            "name": "审核管理"
                        }
                    ]
                },
                {
                    "name": "退货管理"
                }
            ]
        },
        {
            "name": "产品管理",
            "children": [
                {
                    "name": "产品列表"
                },
                {
                    "name": "产品分类"
                }
            ]
        }
    ]
}

const vip={
    "code": 0,
    "message": "vip获取权限成功",
    "data": [
        {
            "name": "订单管理",
            "children": [
                {
                    "name": "订单列表"
                },
                {
                    "name": "生产管理",
                    "children": [
                        {
                            "name": "生产列表"
                        },
                        {
                            "name": "审核管理"
                        }
                    ]
                },
                {
                    "name": "退货管理"
                }
            ]
        }
    ]
}


/* */
router.get('/',role_check, function(req, res, next) {
    console.log(req.role,req.query.role,3333);
    const role=req.role || req.query.role
    // const {role}=req.query
    console.log(req.query);
    if(role==0){
        res.send(vip)
    }else if(role==1){
        res.send(admin)
    }else{
        res.send(vip)
    }
});

module.exports = router;

